<?php

/**
 * DeliveryRule form base class.
 *
 * @method DeliveryRule getObject() Returns the current form's model object
 *
 * @package    tsantek-shop
 * @subpackage form
 * @author     Tomislav Šantek
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseDeliveryRuleForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'           => new sfWidgetFormInputHidden(),
      'shop_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Shop'), 'add_empty' => true)),
      'product_id'   => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Product'), 'add_empty' => true)),
      'region'       => new sfWidgetFormChoice(array('choices' => array('city' => 'city', 'county' => 'county', 'zip' => 'zip', 'country' => 'country'))),
      'region_id'    => new sfWidgetFormInputText(),
      'is_free'      => new sfWidgetFormInputCheckbox(),
      'override_all' => new sfWidgetFormInputCheckbox(),
      'amount'       => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'           => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'shop_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Shop'), 'required' => false)),
      'product_id'   => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Product'), 'required' => false)),
      'region'       => new sfValidatorChoice(array('choices' => array(0 => 'city', 1 => 'county', 2 => 'zip', 3 => 'country'), 'required' => false)),
      'region_id'    => new sfValidatorInteger(),
      'is_free'      => new sfValidatorBoolean(array('required' => false)),
      'override_all' => new sfValidatorBoolean(array('required' => false)),
      'amount'       => new sfValidatorNumber(),
    ));

    $this->widgetSchema->setNameFormat('delivery_rule[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'DeliveryRule';
  }

}
